package com.stary.service;

import java.util.concurrent.Callable;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.stary.code.AutoGenerator;
import com.stary.code.springboot.config.LogBackConfig;
import com.stary.code.springboot.config.MailConfig;
import com.stary.code.springboot.config.MavenConfig;
import com.stary.code.springboot.config.MybatisPlusConfig;
import com.stary.code.springboot.config.SpringBootProjectConfig;
import com.stary.code.springboot.config.data.DataSourceConfig;
import com.stary.code.springboot.config.data.MongoDBConfig;
import com.stary.code.springboot.config.data.RedisConfig;
import com.stary.code.springboot.config.mq.ActiveMQConfig;
import com.stary.code.springboot.config.mq.KafkaConfig;
import com.stary.code.springboot.config.mq.RabbitMQConfig;
import com.stary.code.springboot.config.search.ElasticSearchConfig;
import com.stary.code.springboot.config.search.SolrConfig;

public class GenerateService implements Callable<String>{
	private static final Logger logger=LoggerFactory.getLogger(GenerateService.class);
	private AutoGenerator autoGenerator;
	private MavenConfig mavenConfig;
	private SpringBootProjectConfig springBootProjectConfig;
	private LogBackConfig logBackConfig;
	private MybatisPlusConfig mybatisPlusConfig;
	private DataSourceConfig dataSourceConfig;
	private RedisConfig redisConfig;
	private MongoDBConfig mongoDBConfig;
	private MailConfig mailConfig;
	private ActiveMQConfig activeMQConfig;
	private RabbitMQConfig rabbitMQConfig;
	private KafkaConfig kafkaConfig;
	private SolrConfig solrConfig;
	private ElasticSearchConfig elasticSearchConfig;
	
	
	public SolrConfig getSolrConfig() {
		return solrConfig;
	}


	public void setSolrConfig(SolrConfig solrConfig) {
		this.solrConfig = solrConfig;
	}


	public ElasticSearchConfig getElasticSearchConfig() {
		return elasticSearchConfig;
	}


	public void setElasticSearchConfig(ElasticSearchConfig elasticSearchConfig) {
		this.elasticSearchConfig = elasticSearchConfig;
	}


	public ActiveMQConfig getActiveMQConfig() {
		return activeMQConfig;
	}


	public void setActiveMQConfig(ActiveMQConfig activeMQConfig) {
		this.activeMQConfig = activeMQConfig;
	}


	public RabbitMQConfig getRabbitMQConfig() {
		return rabbitMQConfig;
	}


	public void setRabbitMQConfig(RabbitMQConfig rabbitMQConfig) {
		this.rabbitMQConfig = rabbitMQConfig;
	}


	public KafkaConfig getKafkaConfig() {
		return kafkaConfig;
	}


	public void setKafkaConfig(KafkaConfig kafkaConfig) {
		this.kafkaConfig = kafkaConfig;
	}


	public MailConfig getMailConfig() {
		return mailConfig;
	}


	public void setMailConfig(MailConfig mailConfig) {
		this.mailConfig = mailConfig;
	}


	public RedisConfig getRedisConfig() {
		return redisConfig;
	}


	public void setRedisConfig(RedisConfig redisConfig) {
		this.redisConfig = redisConfig;
	}


	public MongoDBConfig getMongoDBConfig() {
		return mongoDBConfig;
	}


	public void setMongoDBConfig(MongoDBConfig mongoDBConfig) {
		this.mongoDBConfig = mongoDBConfig;
	}


	public DataSourceConfig getDataSourceConfig() {
		return dataSourceConfig;
	}


	public void setDataSourceConfig(DataSourceConfig dataSourceConfig) {
		this.dataSourceConfig = dataSourceConfig;
	}


	public AutoGenerator getAutoGenerator() {
		return autoGenerator;
	}


	public void setAutoGenerator(AutoGenerator autoGenerator) {
		this.autoGenerator = autoGenerator;
	}


	public MavenConfig getMavenConfig() {
		return mavenConfig;
	}


	public void setMavenConfig(MavenConfig mavenConfig) {
		this.mavenConfig = mavenConfig;
	}


	public SpringBootProjectConfig getSpringBootProjectConfig() {
		return springBootProjectConfig;
	}


	public void setSpringBootProjectConfig(
			SpringBootProjectConfig springBootProjectConfig) {
		this.springBootProjectConfig = springBootProjectConfig;
	}


	public LogBackConfig getLogBackConfig() {
		return logBackConfig;
	}


	public void setLogBackConfig(LogBackConfig logBackConfig) {
		this.logBackConfig = logBackConfig;
	}


	public MybatisPlusConfig getMybatisPlusConfig() {
		return mybatisPlusConfig;
	}


	public void setMybatisPlusConfig(MybatisPlusConfig mybatisPlusConfig) {
		this.mybatisPlusConfig = mybatisPlusConfig;
	}


	public GenerateService() {
		super();

	}

	public GenerateService(AutoGenerator autoGenerator,
			MavenConfig mavenConfig,
			SpringBootProjectConfig springBootProjectConfig,
			LogBackConfig logBackConfig, MybatisPlusConfig mybatisPlusConfig,
			DataSourceConfig dataSourceConfig, RedisConfig redisConfig,
			MongoDBConfig mongoDBConfig, MailConfig mailConfig,
			ActiveMQConfig activeMQConfig, RabbitMQConfig rabbitMQConfig,
			KafkaConfig kafkaConfig, SolrConfig solrConfig,
			ElasticSearchConfig elasticSearchConfig) {
		super();
		this.autoGenerator = autoGenerator;
		this.mavenConfig = mavenConfig;
		this.springBootProjectConfig = springBootProjectConfig;
		this.logBackConfig = logBackConfig;
		this.mybatisPlusConfig = mybatisPlusConfig;
		this.dataSourceConfig = dataSourceConfig;
		this.redisConfig = redisConfig;
		this.mongoDBConfig = mongoDBConfig;
		this.mailConfig = mailConfig;
		this.activeMQConfig = activeMQConfig;
		this.rabbitMQConfig = rabbitMQConfig;
		this.kafkaConfig = kafkaConfig;
		this.solrConfig = solrConfig;
		this.elasticSearchConfig = elasticSearchConfig;
	}


	@Override
	public String call() throws Exception{
		String error="1";
		// 设置默认的线程异常捕获处理器
		logger.info("-------->> start generator project ... <<--------");
		autoGenerator.setMavenConfig(mavenConfig)
		.setSpringBootProjectConfig(springBootProjectConfig)
		.setDataSourceConfig(dataSourceConfig)
		.setLogBackConfig(logBackConfig)
		.setMybatisPlusConfig(mybatisPlusConfig)
		.setRedisConfig(redisConfig)
		.setMongoDBConfig(mongoDBConfig)
		.setMailConfig(mailConfig)
		.setActiveMQConfig(activeMQConfig)
		.setRabbitMQConfig(rabbitMQConfig)
		.setKafkaConfig(kafkaConfig)
		.setSolrConfig(solrConfig)
		.setElasticSearchConfig(elasticSearchConfig);	
		autoGenerator.excute();
		Thread.sleep(3000);
		return error;
	}

}
